package com.yuanqi.Controller;

import com.yuanqi.Common.Pojo.Vo.FollowVo;
import com.yuanqi.Common.Pojo.entity.Follow;
import com.yuanqi.Return.Result;
import com.yuanqi.Service.FollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/v1/follow")
public class FollowController {
    @Resource
    FollowService followService;

    /**
     * 关注
     * @param follow
     * @return
     */
    @PostMapping("/add")
    public Result addFollow(@RequestBody Follow follow){
        followService.addFollow(follow);
        return Result.success("关注成功");
    }

    /**
     * 取消关注
     * @param follow
     * @return
     */
    @PostMapping("/cancel")
    public Result cancelFollow(@RequestBody Follow follow){
        followService.cancelFollow(follow);
        return Result.success("取消关注成功");
    }

    /**
     * 互相关注列表
     * @param current
     * @return
     */
    @GetMapping("/eachOther")
    public Result eachOther(Integer current){
      List<FollowVo> list = followService.eachOther(current);
        return Result.success(list);
    }

    /**
     * 粉丝列表
     * @param current
     * @return
     */
    @GetMapping("/followers")
    public Result followers(Integer current){
        List<FollowVo> list  = followService.followers(current);
        return Result.success(list);
    }

    /**
     * 关注列表
     */
    @GetMapping("/concern")
    public Result concern(Integer current){
        List<FollowVo> list = followService.concern(current);
        return Result.success(list);
    }

    /**
     * 获取两个用户的关注情况
     * @return
     */
    @GetMapping("/isFollow")
    public  Result isFollow(Long userId,Long followId)
    {
       Integer isFollow =  followService.isFollow(userId,followId);
   return  Result.success(isFollow);
    }
}
